
class CustomCharReader:

    fileContent = ''
    readLength = 0

    def __init__(self, filePath):
        with open(filePath, 'r') as f:
            for line in f.readlines():
                self.fileContent = self.fileContent + line

    def read(self, charArr, pos, length):
        ext = [None for _ in range(0, pos + length)]
        charArr.clear()
        charArr.extend(ext)
        if self.readLength == len(self.fileContent):
            return -1
        for i in range(pos, pos + length):
            charArr[i] = self.fileContent[self.readLength]
            self.readLength += 1
            if self.readLength == len(self.fileContent):
                return i - pos + 1
        return length

